import { _decorator, Component, director, Event, EventTouch, Label, Layout, log, Node, Sprite, SpriteFrame } from 'cc';
import { Globals } from '../Globals';
import { SkillData, skillType } from '../Data/SkillData';
import { ResourcesUtil } from '../ResourcesUtil';
import { SkillPanelItem } from './SkillPanelItem';
import { Battle } from '../Battle';
import { Player } from '../Player/Player';
const { ccclass, property } = _decorator;

@ccclass('SkillSelectPanel')
export class SkillSelectPanel extends Component {
    private _playerSkillList: skillType[] = []; // 玩家技能栏数据
    private _nameString: string; // 技能名称

    protected onLoad(): void {
        this.node.on(Node.EventType.TOUCH_START, this.onTouchStart, this); // 监听触摸开始事件
    }
    protected onEnable(): void {
        // 获取玩家技能栏数据
        this._playerSkillList = Battle.playerNode.getComponent(Player).skillList;
        // 当面板激活时暂停游戏
        director.pause();
        // 加载技能选择选项
        this.loadSkillItem();
    }
    protected onDisable(): void {
        // 当面板禁用时恢复游戏
        director.resume();
    }
    start() {

    }

    update(deltaTime: number) {

    }
    onTouchStart(event: EventTouch) {
        // 加这个事件是为了防止点击穿透
    }

    /**
     * 
     * @param count 要生成的随机数个数
     * @param min 最小值
     * @param max 最大值
     * @returns  返回一个包含随机数的数组
     */
    getRandomNumbers(count: number, min: number, max: number): number[] {
        const result: number[] = [];
        while (result.length < count) {
            const num = Math.floor(Math.random() * (max - min + 1)) + min;
            if (!result.includes(num)) {
                result.push(num);
            }
        }
        return result;
    }

    // 加载技能选择选项
    loadSkillItem() {
        
    }
}


